import os
import shutil


def tear_down():
    # now the target directory is "classeval_evaluation"
    target_dir = os.path.dirname(__file__)
    if not os.path.exists(target_dir):
        print(f"Target directory {target_dir} does not exist.")
        return
    os.chdir(target_dir)

    file_list = os.listdir()
    reserved_files = ["evaluation.py", "path_util.py", "test_pipeline.py", "README.md", "incremental generation.png", "run.sh", "main.py"]
    for item in file_list:
        if item not in reserved_files and "test_pipeline" not in item and "_pycache__" not in item:
            if os.path.isdir(item):
                shutil.rmtree(item)
            else:
                os.remove(item)

if __name__=="__main__":
    tear_down()